{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "7765UFHoyGx6"
      },
      "source": [
        "##### Copyright 2019 The TensorFlow Authors."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 0,
      "metadata": {
        "cellView": "form",
        "colab": {},
        "colab_type": "code",
        "id": "KVtTDrUNyL7x"
      },
      "outputs": [],
      "source": [
        "#@title Licensed under the Apache License, Version 2.0 (the \"License\");\n",
        "# you may not use this file except in compliance with the License.\n",
        "# You may obtain a copy of the License at\n",
        "#\n",
        "# https://www.apache.org/licenses/LICENSE-2.0\n",
        "#\n",
        "# Unless required by applicable law or agreed to in writing, software\n",
        "# distributed under the License is distributed on an \"AS IS\" BASIS,\n",
        "# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
        "# See the License for the specific language governing permissions and\n",
        "# limitations under the License."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "xPYxZMrWyA0N"
      },
      "source": [
        "#How to train Boosted Trees models in TensorFlow"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "p_vOREjRx-Y0"
      },
      "source": [
        "\u003ctable class=\"tfo-notebook-buttons\" align=\"left\"\u003e\n",
        "  \u003ctd\u003e\n",
        "    \u003ca target=\"_blank\" href=\"https://www.tensorflow.org/tutorials/estimators/boosted_trees\"\u003e\u003cimg src=\"https://www.tensorflow.org/images/tf_logo_32px.png\" /\u003eView on TensorFlow.org\u003c/a\u003e\n",
        "  \u003c/td\u003e\n",
        "  \u003ctd\u003e\n",
        "    \u003ca target=\"_blank\" href=\"https://colab.research.google.com/github/tensorflow/docs/blob/master/site/en/tutorials/estimators/boosted_trees.ipynb\"\u003e\u003cimg src=\"https://www.tensorflow.org/images/colab_logo_32px.png\" /\u003eRun in Google Colab\u003c/a\u003e\n",
        "  \u003c/td\u003e\n",
        "  \u003ctd\u003e\n",
        "    \u003ca target=\"_blank\" href=\"https://github.com/tensorflow/docs/tree/master/site/en/tutorials/estimators/boosted_trees.ipynb\"\u003e\u003cimg src=\"https://www.tensorflow.org/images/GitHub-Mark-32px.png\"\u003eView source on GitHub\u003c/a\u003e\n",
        "  \u003c/td\u003e\n",
        "\u003c/table\u003e"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "dW3r7qVxzqN5"
      },
      "source": [
        "This tutorial is an end-to-end walkthrough of training a Gradient Boosting  model using decision trees with the `tf.estimator` API. Boosted Trees models are among the most popular and effective machine learning approaches for both regression and classification. It is an ensemble technique that combines the predictions from several (think 10s, 100s or even 1000s) tree models.\n",
        "\n",
        "Boosted Trees models are popular with many machine learning practioners as they can achieve impressive performance with minimal hyperparameter tuning."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "eylrTPAN3rJV"
      },
      "source": [
        "## Load the titanic dataset\n",
        "You will be using the titanic dataset, where the (rather morbid) goal is to predict passenger survival, given characteristics such as gender, age, class, etc."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 0,
      "metadata": {
        "colab": {},
        "colab_type": "code",
        "id": "KuhAiPfZ3rJW"
      },
      "outputs": [],
      "source": [
        "from __future__ import absolute_import, division, print_function, unicode_literals\n",
        "\n",
        "from matplotlib import pyplot as plt\n",
        "\n",
        "import numpy as np\n",
        "import pandas as pd\n",
        "import tensorflow as tf\n",
        "\n",
        "tf.enable_eager_execution()\n",
        "\n",
        "tf.logging.set_verbosity(tf.logging.ERROR)\n",
        "tf.set_random_seed(123)\n",
        "\n",
        "# Load dataset.\n",
        "dftrain = pd.read_csv('https://storage.googleapis.com/tfbt/titanic_train.csv')\n",
        "dfeval = pd.read_csv('https://storage.googleapis.com/tfbt/titanic_eval.csv')\n",
        "y_train = dftrain.pop('survived')\n",
        "y_eval = dfeval.pop('survived')"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "3ioodHdVJVdA"
      },
      "source": [
        "The dataset consists of a training set and an evaluation set:\n",
        "\n",
        "* `dftrain` and `y_train` are the *training set*—the data the model uses to learn.\n",
        "* The model is tested against the *eval set*, `dfeval`, and `y_eval`.\n",
        "\n",
        "For training you will use the following features:\n",
        "\n",
        "\n",
        "\u003ctable\u003e\n",
        "  \u003ctr\u003e\n",
        "    \u003cth\u003eFeature Name\u003c/th\u003e\n",
        "    \u003cth\u003eDescription\u003c/th\u003e\n",
        "  \u003c/tr\u003e\n",
        "  \u003ctr\u003e\n",
        "    \u003ctd\u003esex\u003c/td\u003e\n",
        "    \u003ctd\u003eGender of passenger\u003c/td\u003e\n",
        "  \u003c/tr\u003e\n",
        "  \u003ctr\u003e\n",
        "    \u003ctd\u003eage\u003c/td\u003e\n",
        "    \u003ctd\u003eAge of passenger\u003c/td\u003e\n",
        "  \u003c/tr\u003e\n",
        "    \u003ctr\u003e\n",
        "    \u003ctd\u003en_siblings_spouses\u003c/td\u003e\n",
        "    \u003ctd\u003e# siblings and partners aboard\u003c/td\u003e\n",
        "  \u003c/tr\u003e\n",
        "    \u003ctr\u003e\n",
        "    \u003ctd\u003eparch\u003c/td\u003e\n",
        "    \u003ctd\u003e# of parents and children aboard\u003c/td\u003e\n",
        "  \u003c/tr\u003e\n",
        "    \u003ctr\u003e\n",
        "    \u003ctd\u003efare\u003c/td\u003e\n",
        "    \u003ctd\u003eFare passenger paid.\u003c/td\u003e\n",
        "  \u003c/tr\u003e\n",
        "    \u003ctr\u003e\n",
        "    \u003ctd\u003eclass\u003c/td\u003e\n",
        "    \u003ctd\u003ePassenger's class on ship\u003c/td\u003e\n",
        "  \u003c/tr\u003e\n",
        "    \u003ctr\u003e\n",
        "    \u003ctd\u003edeck\u003c/td\u003e\n",
        "    \u003ctd\u003eWhich deck passenger was on\u003c/td\u003e\n",
        "  \u003c/tr\u003e\n",
        "    \u003ctr\u003e\n",
        "    \u003ctd\u003eembark_town\u003c/td\u003e\n",
        "    \u003ctd\u003eWhich town passenger embarked from\u003c/td\u003e\n",
        "  \u003c/tr\u003e\n",
        "    \u003ctr\u003e\n",
        "    \u003ctd\u003ealone\u003c/td\u003e\n",
        "    \u003ctd\u003eIf passenger was alone\u003c/td\u003e\n",
        "  \u003c/tr\u003e\n",
        "\u003c/table\u003e"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "AoPiWsJALr-k"
      },
      "source": [
        "## Explore the data"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "slcat1yzmzw5"
      },
      "source": [
        "Let's first preview some of the data and create summary statistics on the training set."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 0,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 204
        },
        "colab_type": "code",
        "id": "15PLelXBlxEW",
        "outputId": "6feb338e-8d99-4795-cce6-14c92c2e7832"
      },
      "outputs": [
        {
          "data": {
            "text/html": [
              "\u003cdiv\u003e\n",
              "\u003cstyle scoped\u003e\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "\u003c/style\u003e\n",
              "\u003ctable border=\"1\" class=\"dataframe\"\u003e\n",
              "  \u003cthead\u003e\n",
              "    \u003ctr style=\"text-align: right;\"\u003e\n",
              "      \u003cth\u003e\u003c/th\u003e\n",
              "      \u003cth\u003esex\u003c/th\u003e\n",
              "      \u003cth\u003eage\u003c/th\u003e\n",
              "      \u003cth\u003en_siblings_spouses\u003c/th\u003e\n",
              "      \u003cth\u003eparch\u003c/th\u003e\n",
              "      \u003cth\u003efare\u003c/th\u003e\n",
              "      \u003cth\u003eclass\u003c/th\u003e\n",
              "      \u003cth\u003edeck\u003c/th\u003e\n",
              "      \u003cth\u003eembark_town\u003c/th\u003e\n",
              "      \u003cth\u003ealone\u003c/th\u003e\n",
              "    \u003c/tr\u003e\n",
              "  \u003c/thead\u003e\n",
              "  \u003ctbody\u003e\n",
              "    \u003ctr\u003e\n",
              "      \u003cth\u003e0\u003c/th\u003e\n",
              "      \u003ctd\u003emale\u003c/td\u003e\n",
              "      \u003ctd\u003e22.0\u003c/td\u003e\n",
              "      \u003ctd\u003e1\u003c/td\u003e\n",
              "      \u003ctd\u003e0\u003c/td\u003e\n",
              "      \u003ctd\u003e7.2500\u003c/td\u003e\n",
              "      \u003ctd\u003eThird\u003c/td\u003e\n",
              "      \u003ctd\u003eunknown\u003c/td\u003e\n",
              "      \u003ctd\u003eSouthampton\u003c/td\u003e\n",
              "      \u003ctd\u003en\u003c/td\u003e\n",
              "    \u003c/tr\u003e\n",
              "    \u003ctr\u003e\n",
              "      \u003cth\u003e1\u003c/th\u003e\n",
              "      \u003ctd\u003efemale\u003c/td\u003e\n",
              "      \u003ctd\u003e38.0\u003c/td\u003e\n",
              "      \u003ctd\u003e1\u003c/td\u003e\n",
              "      \u003ctd\u003e0\u003c/td\u003e\n",
              "      \u003ctd\u003e71.2833\u003c/td\u003e\n",
              "      \u003ctd\u003eFirst\u003c/td\u003e\n",
              "      \u003ctd\u003eC\u003c/td\u003e\n",
              "      \u003ctd\u003eCherbourg\u003c/td\u003e\n",
              "      \u003ctd\u003en\u003c/td\u003e\n",
              "    \u003c/tr\u003e\n",
              "    \u003ctr\u003e\n",
              "      \u003cth\u003e2\u003c/th\u003e\n",
              "      \u003ctd\u003efemale\u003c/td\u003e\n",
              "      \u003ctd\u003e26.0\u003c/td\u003e\n",
              "      \u003ctd\u003e0\u003c/td\u003e\n",
              "      \u003ctd\u003e0\u003c/td\u003e\n",
              "      \u003ctd\u003e7.9250\u003c/td\u003e\n",
              "      \u003ctd\u003eThird\u003c/td\u003e\n",
              "      \u003ctd\u003eunknown\u003c/td\u003e\n",
              "      \u003ctd\u003eSouthampton\u003c/td\u003e\n",
              "      \u003ctd\u003ey\u003c/td\u003e\n",
              "    \u003c/tr\u003e\n",
              "    \u003ctr\u003e\n",
              "      \u003cth\u003e3\u003c/th\u003e\n",
              "      \u003ctd\u003efemale\u003c/td\u003e\n",
              "      \u003ctd\u003e35.0\u003c/td\u003e\n",
              "      \u003ctd\u003e1\u003c/td\u003e\n",
              "      \u003ctd\u003e0\u003c/td\u003e\n",
              "      \u003ctd\u003e53.1000\u003c/td\u003e\n",
              "      \u003ctd\u003eFirst\u003c/td\u003e\n",
              "      \u003ctd\u003eC\u003c/td\u003e\n",
              "      \u003ctd\u003eSouthampton\u003c/td\u003e\n",
              "      \u003ctd\u003en\u003c/td\u003e\n",
              "    \u003c/tr\u003e\n",
              "    \u003ctr\u003e\n",
              "      \u003cth\u003e4\u003c/th\u003e\n",
              "      \u003ctd\u003emale\u003c/td\u003e\n",
              "      \u003ctd\u003e28.0\u003c/td\u003e\n",
              "      \u003ctd\u003e0\u003c/td\u003e\n",
              "      \u003ctd\u003e0\u003c/td\u003e\n",
              "      \u003ctd\u003e8.4583\u003c/td\u003e\n",
              "      \u003ctd\u003eThird\u003c/td\u003e\n",
              "      \u003ctd\u003eunknown\u003c/td\u003e\n",
              "      \u003ctd\u003eQueenstown\u003c/td\u003e\n",
              "      \u003ctd\u003ey\u003c/td\u003e\n",
              "    \u003c/tr\u003e\n",
              "  \u003c/tbody\u003e\n",
              "\u003c/table\u003e\n",
              "\u003c/div\u003e"
            ],
            "text/plain": [
              "      sex   age  n_siblings_spouses  parch     fare  class     deck  \\\n",
              "0    male  22.0                   1      0   7.2500  Third  unknown\n",
              "1  female  38.0                   1      0  71.2833  First        C\n",
              "2  female  26.0                   0      0   7.9250  Third  unknown\n",
              "3  female  35.0                   1      0  53.1000  First        C\n",
              "4    male  28.0                   0      0   8.4583  Third  unknown\n",
              "\n",
              "   embark_town alone\n",
              "0  Southampton     n\n",
              "1    Cherbourg     n\n",
              "2  Southampton     y\n",
              "3  Southampton     n\n",
              "4   Queenstown     y"
            ]
          },
          "execution_count": 4,
          "metadata": {
            "tags": []
          },
          "output_type": "execute_result"
        }
      ],
      "source": [
        "dftrain.head()"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 0,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 297
        },
        "colab_type": "code",
        "id": "j2hiM4ETmqP0",
        "outputId": "eafbd386-1cc2-4818-b440-08972cc0a85c"
      },
      "outputs": [
        {
          "data": {
            "text/html": [
              "\u003cdiv\u003e\n",
              "\u003cstyle scoped\u003e\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "\u003c/style\u003e\n",
              "\u003ctable border=\"1\" class=\"dataframe\"\u003e\n",
              "  \u003cthead\u003e\n",
              "    \u003ctr style=\"text-align: right;\"\u003e\n",
              "      \u003cth\u003e\u003c/th\u003e\n",
              "      \u003cth\u003eage\u003c/th\u003e\n",
              "      \u003cth\u003en_siblings_spouses\u003c/th\u003e\n",
              "      \u003cth\u003eparch\u003c/th\u003e\n",
              "      \u003cth\u003efare\u003c/th\u003e\n",
              "    \u003c/tr\u003e\n",
              "  \u003c/thead\u003e\n",
              "  \u003ctbody\u003e\n",
              "    \u003ctr\u003e\n",
              "      \u003cth\u003ecount\u003c/th\u003e\n",
              "      \u003ctd\u003e627.000000\u003c/td\u003e\n",
              "      \u003ctd\u003e627.000000\u003c/td\u003e\n",
              "      \u003ctd\u003e627.000000\u003c/td\u003e\n",
              "      \u003ctd\u003e627.000000\u003c/td\u003e\n",
              "    \u003c/tr\u003e\n",
              "    \u003ctr\u003e\n",
              "      \u003cth\u003emean\u003c/th\u003e\n",
              "      \u003ctd\u003e29.631308\u003c/td\u003e\n",
              "      \u003ctd\u003e0.545455\u003c/td\u003e\n",
              "      \u003ctd\u003e0.379585\u003c/td\u003e\n",
              "      \u003ctd\u003e34.385399\u003c/td\u003e\n",
              "    \u003c/tr\u003e\n",
              "    \u003ctr\u003e\n",
              "      \u003cth\u003estd\u003c/th\u003e\n",
              "      \u003ctd\u003e12.511818\u003c/td\u003e\n",
              "      \u003ctd\u003e1.151090\u003c/td\u003e\n",
              "      \u003ctd\u003e0.792999\u003c/td\u003e\n",
              "      \u003ctd\u003e54.597730\u003c/td\u003e\n",
              "    \u003c/tr\u003e\n",
              "    \u003ctr\u003e\n",
              "      \u003cth\u003emin\u003c/th\u003e\n",
              "      \u003ctd\u003e0.750000\u003c/td\u003e\n",
              "      \u003ctd\u003e0.000000\u003c/td\u003e\n",
              "      \u003ctd\u003e0.000000\u003c/td\u003e\n",
              "      \u003ctd\u003e0.000000\u003c/td\u003e\n",
              "    \u003c/tr\u003e\n",
              "    \u003ctr\u003e\n",
              "      \u003cth\u003e25%\u003c/th\u003e\n",
              "      \u003ctd\u003e23.000000\u003c/td\u003e\n",
              "      \u003ctd\u003e0.000000\u003c/td\u003e\n",
              "      \u003ctd\u003e0.000000\u003c/td\u003e\n",
              "      \u003ctd\u003e7.895800\u003c/td\u003e\n",
              "    \u003c/tr\u003e\n",
              "    \u003ctr\u003e\n",
              "      \u003cth\u003e50%\u003c/th\u003e\n",
              "      \u003ctd\u003e28.000000\u003c/td\u003e\n",
              "      \u003ctd\u003e0.000000\u003c/td\u003e\n",
              "      \u003ctd\u003e0.000000\u003c/td\u003e\n",
              "      \u003ctd\u003e15.045800\u003c/td\u003e\n",
              "    \u003c/tr\u003e\n",
              "    \u003ctr\u003e\n",
              "      \u003cth\u003e75%\u003c/th\u003e\n",
              "      \u003ctd\u003e35.000000\u003c/td\u003e\n",
              "      \u003ctd\u003e1.000000\u003c/td\u003e\n",
              "      \u003ctd\u003e0.000000\u003c/td\u003e\n",
              "      \u003ctd\u003e31.387500\u003c/td\u003e\n",
              "    \u003c/tr\u003e\n",
              "    \u003ctr\u003e\n",
              "      \u003cth\u003emax\u003c/th\u003e\n",
              "      \u003ctd\u003e80.000000\u003c/td\u003e\n",
              "      \u003ctd\u003e8.000000\u003c/td\u003e\n",
              "      \u003ctd\u003e5.000000\u003c/td\u003e\n",
              "      \u003ctd\u003e512.329200\u003c/td\u003e\n",
              "    \u003c/tr\u003e\n",
              "  \u003c/tbody\u003e\n",
              "\u003c/table\u003e\n",
              "\u003c/div\u003e"
            ],
            "text/plain": [
              "              age  n_siblings_spouses       parch        fare\n",
              "count  627.000000          627.000000  627.000000  627.000000\n",
              "mean    29.631308            0.545455    0.379585   34.385399\n",
              "std     12.511818            1.151090    0.792999   54.597730\n",
              "min      0.750000            0.000000    0.000000    0.000000\n",
              "25%     23.000000            0.000000    0.000000    7.895800\n",
              "50%     28.000000            0.000000    0.000000   15.045800\n",
              "75%     35.000000            1.000000    0.000000   31.387500\n",
              "max     80.000000            8.000000    5.000000  512.329200"
            ]
          },
          "execution_count": 5,
          "metadata": {
            "tags": []
          },
          "output_type": "execute_result"
        }
      ],
      "source": [
        "dftrain.describe()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "-IR0e8V-LyJ4"
      },
      "source": [
        "There are 627 and 264 examples in the training and evaluation sets, respectively."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 0,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 34
        },
        "colab_type": "code",
        "id": "_1NwYqGwDjFf",
        "outputId": "203bf969-41cf-42e7-82bf-9daa2b0905ba"
      },
      "outputs": [
        {
          "data": {
            "text/plain": [
              "(627, 264)"
            ]
          },
          "execution_count": 6,
          "metadata": {
            "tags": []
          },
          "output_type": "execute_result"
        }
      ],
      "source": [
        "dftrain.shape[0], dfeval.shape[0]"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "28UFJ4KSMK3V"
      },
      "source": [
        "The majority of passengers are in their 20's and 30's."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 0,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 269
        },
        "colab_type": "code",
        "id": "CaVDmZtuDfux",
        "outputId": "469b350b-f85c-43d5-c9f5-bf567234c062"
      },
      "outputs": [
        {
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD8CAYAAAB5Pm/hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAFcBJREFUeJzt3X2MXXd95/H3dxOaUk9lJ032yutk\nO0FrUgW7GDyiqaBohrTUhIoAqthEEU1KugNSoqWrSK1DV6VdhJR2eWir7tJ1mzRhSz2hhEDWSUtT\nN9MsqwbwgBs7T40DBjxrbBIShwkoi+l3/7hn2tvp2DP3nvtw5pf3S7qae37nnHs+vvf6M3d+9yky\nE0lSuf7VqANIkgbLopekwln0klQ4i16SCmfRS1LhLHpJKpxFL0mFs+glqXAWvSQV7sxRBwA499xz\nc3x8vKt9nnvuOdatWzeYQDWYq3tNzdbUXNDcbE3NBc3NVifX3Nzck5l53oobZuZpT8AFwH3Aw8BD\nwLur8XOAe4HHq59nV+MB/B5wCHgQeOVKx9i+fXt267777ut6n2EwV/eamq2puTKbm62puTKbm61O\nLmBfrtCvmbmqqZuTwA2ZeTFwCXBdRFwM7AT2ZuZmYG+1DPAGYHN1mgY+sopjSJIGZMWiz8yjmfnF\n6vy3gUeATcDlwG3VZrcBb67OXw58tPqF8wCwISI29j25JGlVIrv49MqIGAfuB7YAX8vMDdV4AE9n\n5oaI2APclJmfrdbtBX41M/ctuaxp2o/4abVa22dmZroKvrCwwNjYWFf7DIO5utfUbE3NBc3N1tRc\n0NxsdXJNTU3NZebEihuuZn6n+mUwBswBb62Wn1my/unq5x7gNR3je4GJ0122c/SD19Rcmc3N1tRc\nmc3N1tRcmc3N1pQ5eiLiRcAdwMcy85PV8LHFKZnq5/FqfJ72E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QREcDNwCOZ+aGmZIuI8yJiQ3X+xbSfN3iEduH//KhyZeaNmXl+Zo7Tvk/9dWZe\nNepcABGxLiJ+ePE87TnngzTgfpaZ3wC+HhEXVUOXAg83IVvlSv5p2gZGn+trwCUR8UPV/9HF62vw\n97NRPUlS4wmNy4C/pz23+2sjzrKb9lzb92g/urmW9tzuXuBx4K+Ac0aQ6zW0/yx9ENhfnS4bdTbg\nx4EvVbkOAr9ejb8E+DxwiPaf2WeN8DadBPY0JVeV4e+q00OL9/lR35Yd+bYB+6rb9FPA2U3IRnta\n5ClgfcdYE3L9JvBodf//n8BZw7if+c5YSSrcWpu6kSR1yaKXpMJZ9JJUOItekgpn0UtS4Sx6SSqc\nRS9JhbPoJalw/x8MqdwquVi2jAAAAABJRU5ErkJggg==\n",
            "text/plain": [
              "\u003cFigure size 432x288 with 1 Axes\u003e"
            ]
          },
          "metadata": {
            "tags": []
          },
          "output_type": "display_data"
        }
      ],
      "source": [
        "dftrain.age.hist(bins=20)\n",
        "plt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "1pifWiCoMbR5"
      },
      "source": [
        "There are approximately twice as male passengers as female passengers aboard."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 0,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 269
        },
        "colab_type": "code",
        "id": "-WazAq30MO5J",
        "outputId": "29f1fdc2-8130-4bd2-ddf7-b3b8d340fdfe"
      },
      "outputs": [
        {
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYoAAAD8CAYAAABpcuN4AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAADJpJREFUeJzt3H+sZHdZx/HPQ7fdmpa0QhtSKLi0\nNhJSoa2loiIB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UBLKABo\nCQUArf8F3K41wJMvgxcAAAAASUVORK5CYII=\n",
            "text/plain": [
              "\u003cFigure size 432x288 with 1 Axes\u003e"
            ]
          },
          "metadata": {
            "tags": []
          },
          "output_type": "display_data"
        }
      ],
      "source": [
        "dftrain.sex.value_counts().plot(kind='barh')\n",
        "plt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "7_XkxrpmmVU_"
      },
      "source": [
        "The majority of passengers were in the \"third\" class."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 0,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 269
        },
        "colab_type": "code",
        "id": "zZ3PvVy4l4gI",
        "outputId": "32968da4-e263-477b-b285-ea523f444929"
      },
      "outputs": [
        {
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYwAAAD8CAYAAABkbJM/AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAADgBJREFUeJzt3X2MpWddxvHv5XZbFtu09iW4lOK0\npdG0hW7bRUErIqLyoha0CsZoY0w2sfjCH0ZLmpDVSALiK6RISgRKqVBFGgloBGwBg9o6W/YV6Iu0\nRkqhaU0LxVpl/fnHebYM487Or7Mz85wzfD/JyT7nPs8555p7zs619/OcnZOqQpKk5XzL2AEkSbPB\nwpAktVgYkqQWC0OS1GJhSJJaLAxJUouFIUlqsTAkSS0WhiSp5ZixA6ymU089tebm5saOIUkzZdeu\nXQ9U1WnL7behCmNubo75+fmxY0jSTEnyb539PCQlSWqxMCRJLRaGJKnFwpAktVgYkqQWC0OS1GJh\nSJJaLAxJUouFIUlqsTAkSS0WhiSpxcKQJLVYGJKkFgtDktRiYUiSWiwMSVLLhvoApQMPHuCZ1z5z\n7BhaA/su3zd2BOmbnis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evg/7\ngO1TmP26Idve4S/O1gX7XzVkvx148Yi5L2FyuGkvsHu4vGQW5v0I2Wdh3p8FfGrIuB947TB+FpMS\nuwv4S+C4YfxJw/W7htvPmrLcNw1zvh94N19/J9WKXy/+T29JUstGOCQlSVoHFoYkqcXCkCS1WBiS\npBYLQ5LUYmFIklosDElSi4UhSWr5P8Ikz3s2FVuAAAAAAElFTkSuQmCC\n",
            "text/plain": [
              "\u003cFigure size 432x288 with 1 Axes\u003e"
            ]
          },
          "metadata": {
            "tags": []
          },
          "output_type": "display_data"
        }
      ],
      "source": [
        "(dftrain['class']\n",
        "  .value_counts()\n",
        "  .plot(kind='barh'))\n",
        "plt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "HM5SlwlxmZMT"
      },
      "source": [
        "Most passengers embarked from Southampton."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 0,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 269
        },
        "colab_type": "code",
        "id": "RVTSrdr4mZaC",
        "outputId": "be027e44-2a95-4dda-cb6e-71cb372ad722"
      },
      "outputs": [
        {
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAaoAAAD8CAYAAAAmL+CoAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAEw1JREFUeJzt3X2w5mV93/H3x+Vht8FAeChZAT0C\nSxhWdJUNdRUoENqh4kiJ1K06FaqTjY2dio01pHYS0g4dDLEgAZOSFsHWEKsBTWkmkfDkDiC4C8s+\n8bA82aoIYoRAKqvsfvvHfR17u+7Zs3vO2XNfu/t+zZw5v9/1e7i+v2uY/cx13T/uk6pCkqRevWLU\nBUiStC0GlSSpawaVJKlrBpUkqWsGlSSpawaVJKlrBpUkqWsG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gkiR1zaCSJHXNoJIkdc2gkiR1zaCSJHXNoJIk\nde3/ActhPKnN3fksAAAAAElFTkSuQmCC\n",
            "text/plain": [
              "\u003cFigure size 432x288 with 1 Axes\u003e"
            ]
          },
          "metadata": {
            "tags": []
          },
          "output_type": "display_data"
        }
      ],
      "source": [
        "(dftrain['embark_town']\n",
        "  .value_counts()\n",
        "  .plot(kind='barh'))\n",
        "plt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "aTn1niLPob3x"
      },
      "source": [
        "Females have a much higher chance of surviving vs. males. This will clearly be a predictive feature for the model."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 0,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 283
        },
        "colab_type": "code",
        "id": "Eh3KW5oYkaNS",
        "outputId": "9764ab08-7104-43af-fbd0-cabb6cc21ea5"
      },
      "outputs": [
        {
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZgAAAEKCAYAAAAvlUMdAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAD6pJREFUeJzt3XusZXV5xvHvA6NQAdEKpiDiVDoW\nKQWRES9pCaQWLURAQcSqlZRCvBRjLKZaq5lKVSraq1rF1mKNFoSSileqAhopoIPDpYggyjSCpPU6\nokQr8PaPvaZuhjPMnsu79z4z30+yk7X2+Z29nr3OOfOctX5z1kpVIUnSlrbdrANIkrZOFowkqYUF\nI0lqYcFIklpYMJKkFhaMJKmFBSNJamHBSJJaWDCSpBZLZh1glnbbbbdaunTprGNI0qJy9dVXf6eq\ndt/QuG26YJYuXcrKlStnHUOSFpUk/zXJOE+RSZJaWDCSpBYWjCSphQUjSWphwUiSWlgwkqQWFowk\nqYUFI0lqYcFIklpYMJKkF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E3P8V+rahlkw0qZ5PvBuRhcMfCVAkmcBq6pqoy4IOIkk26/vY1V1ZFVN/VLv\n0oZYMNKm+RnwEGAH4J7hMkOvZHQRzQUlee5wxHNtks8Pz52U5B1jYz6W5LBh+UdJ3p7kWuC1Sc4f\nG3dYko8Ny6uT7JbkzCQvHxuzIsnpw/Krk3xpuEDln23B/SCtlwUjbZoPMbq0+aeBNzO6r9AH6ue3\nLFjIG4BnVNWBjO5HsyE7AVcN488Enpxkp+Fjz2N0PbVx5wEnjK2fAJyX5AhG1+E6BHgCcHCSQyfY\nvrRZLBhpE1TVmqo6qqqWA19mdG2zC5K8d7iE/VMX+LTLgXOSnMLoZk8bcg/wr8P27gY+BTxrOFo6\nCvjIOplWAY9MsmeSA4HvV9U3gSOGx6oh675M98KP2kYtmXUAaSvweuBNjOZlvsDoxnUXAs8YH1RV\nL0nyZEblcHWSg4G7ue8vejuOLf+k7nsJ93OBPwS+x+hCnXcukOV84Hjglxgd0cDoulxvqar3bNrb\nkzaNRzDSZkiyDNirqi5jNCdzL6O7AP7CAmP3qaqrquoNwLcZXSp9NfCEJNsNN+465AE29zngiYzu\n1rju6bG1zmN0VfDjGZUNwMXA7yfZecjxqCSP3Jj3KW0Kj2CkzfMmRvfAgdE9Pf4NeA2j+ZZ1nTUU\nUoDPMrpCLcCtjK76eyOjU1gLqqp7hon9k4AXr2fMDUl2AW6vqjuG5/49yeOBK4a7gf8IeCEw7dsI\naxvj1ZQlSS08RSZJamHBSJJaWDCSpBYWjCSphQUjSWphwUiSWlgwkqQWFowkqcX/AWO4AddFyNfE\nAAAAAElFTkSuQmCC\n",
            "text/plain": [
              "\u003cFigure size 432x288 with 1 Axes\u003e"
            ]
          },
          "metadata": {
            "tags": []
          },
          "output_type": "display_data"
        }
      ],
      "source": [
        "ax = (pd.concat([dftrain, y_train], axis=1)\\\n",
        "  .groupby('sex')\n",
        "  .survived\n",
        "  .mean()\n",
        "  .plot(kind='barh'))\n",
        "ax.set_xlabel('% survive')\n",
        "plt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "krkRHuMp3rJn"
      },
      "source": [
        "## Create feature columns and input functions\n",
        "The Gradient Boosting estimator can utilize both numeric and categorical features. Feature columns work with all TensorFlow estimators and their purpose is to define the features used for modeling. Additionally they provide some feature engineering capabilities like one-hot-encoding, normalization, and bucketization. In this tutorial, the fields in `CATEGORICAL_COLUMNS` are transformed from categorical columns to one-hot-encoded columns ([indicator column](https://www.tensorflow.org/api_docs/python/tf/feature_column/indicator_column)):"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 0,
      "metadata": {
        "colab": {},
        "colab_type": "code",
        "id": "upaNWxcF3rJn"
      },
      "outputs": [],
      "source": [
        "fc = tf.feature_column\n",
        "CATEGORICAL_COLUMNS = ['sex', 'n_siblings_spouses', 'parch', 'class', 'deck',\n",
        "                       'embark_town', 'alone']\n",
        "NUMERIC_COLUMNS = ['age', 'fare']\n",
        "\n",
        "def one_hot_cat_column(feature_name, vocab):\n",
        "  return fc.indicator_column(\n",
        "      fc.categorical_column_with_vocabulary_list(feature_name,\n",
        "                                                 vocab))\n",
        "feature_columns = []\n",
        "for feature_name in CATEGORICAL_COLUMNS:\n",
        "  # Need to one-hot encode categorical features.\n",
        "  vocabulary = dftrain[feature_name].unique()\n",
        "  feature_columns.append(one_hot_cat_column(feature_name, vocabulary))\n",
        "\n",
        "for feature_name in NUMERIC_COLUMNS:\n",
        "  feature_columns.append(fc.numeric_column(feature_name,\n",
        "                                           dtype=tf.float32))"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "74GNtFpStSAz"
      },
      "source": [
        "You can view the transformation that a feature column produces. For example, here is the output when using the `indicator_column` on a single example:"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 0,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 51
        },
        "colab_type": "code",
        "id": "Eaq79D9FtmF8",
        "outputId": "49cf07a9-6ec8-4a7d-8f50-cccd00ff9e00"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Feature value: \"Third\"\n",
            "One-hot encoded:  [[0. 0. 1.]]\n"
          ]
        }
      ],
      "source": [
        "example = dftrain.head(1)\n",
        "class_fc = one_hot_cat_column('class', ('First', 'Second', 'Third'))\n",
        "print('Feature value: \"{}\"'.format(example['class'].iloc[0]))\n",
        "print('One-hot encoded: ', fc.input_layer(dict(example), [class_fc]).numpy())"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "YbCUn3nCusC3"
      },
      "source": [
        "Additionally, you can view all of the feature column transformations together:"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 0,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 85
        },
        "colab_type": "code",
        "id": "omIYcsVws3g0",
        "outputId": "beab4b8e-efb4-470a-8aee-81635b27233c"
      },
      "outputs": [
        {
          "data": {
            "text/plain": [
              "array([[22.  ,  1.  ,  0.  ,  1.  ,  0.  ,  0.  ,  1.  ,  0.  ,  0.  ,\n",
              "         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  1.  ,  0.  ,  0.  ,  0.  ,\n",
              "         7.25,  1.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  1.  ,\n",
              "         0.  ,  0.  ,  0.  ,  0.  ,  0.  ,  1.  ,  0.  ]], dtype=float32)"
            ]
          },
          "execution_count": 14,
          "metadata": {
            "tags": []
          },
          "output_type": "execute_result"
        }
      ],
      "source": [
        "fc.input_layer(dict(example), feature_columns).numpy()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "-UOlROp33rJo"
      },
      "source": [
        "Next you need to create the input functions. These will specify how data will be read into our model for both training and inference. You will use the `from_tensor_slices` method in the [`tf.data`](https://www.tensorflow.org/api_docs/python/tf/data) API to read in data directly from Pandas. This is suitable for smaller, in-memory datasets. For larger datasets, the tf.data API supports a variety of file formats (including [csv](https://www.tensorflow.org/api_docs/python/tf/data/experimental/make_csv_dataset)) so that you can process datasets that do not fit in memory."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 0,
      "metadata": {
        "colab": {},
        "colab_type": "code",
        "id": "9dquwCQB3rJp"
      },
      "outputs": [],
      "source": [
        "# Use entire batch since this is such a small dataset.\n",
        "NUM_EXAMPLES = len(y_train)\n",
        "\n",
        "def make_input_fn(X, y, n_epochs=None, shuffle=True):\n",
        "  def input_fn():\n",
        "    dataset = tf.data.Dataset.from_tensor_slices((dict(X), y))\n",
        "    if shuffle:\n",
        "      dataset = dataset.shuffle(NUM_EXAMPLES)\n",
        "    # For training, cycle thru dataset as many times as need (n_epochs=None).\n",
        "    dataset = dataset.repeat(n_epochs)\n",
        "    # In memory training doesn't use batching.\n",
        "    dataset = dataset.batch(NUM_EXAMPLES)\n",
        "    return dataset\n",
        "  return input_fn\n",
        "\n",
        "# Training and evaluation input functions.\n",
        "train_input_fn = make_input_fn(dftrain, y_train)\n",
        "eval_input_fn = make_input_fn(dfeval, y_eval, shuffle=False, n_epochs=1)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "HttfNNlN3rJr"
      },
      "source": [
        "## Train and evaluate the model\n",
        "\n",
        "Below you will do the following steps:\n",
        "\n",
        "1. Initialize the model, specifying the features and hyperparameters.\n",
        "2. Feed the training data to the model using the `train_input_fn` and train the model using the `train` function.\n",
        "3. You will assess model performance using the evaluation set—in this example, the `dfeval` DataFrame. You will verify that the predictions match the labels from the `y_eval` array.\n",
        "\n",
        "Before training a Boosted Trees model, let's first train a linear classifier (logistic regression model). It is best practice to start with simpler model to establish a benchmark."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 0,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 51
        },
        "colab_type": "code",
        "id": "JPOGpmmq3rJr",
        "outputId": "013119a5-9360-4193-9088-ee7990e3ab71"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Accuracy :  0.78409094\n",
            "Dummy model:  0.625\n"
          ]
        }
      ],
      "source": [
        "linear_est = tf.estimator.LinearClassifier(feature_columns)\n",
        "\n",
        "# Train model.\n",
        "linear_est.train(train_input_fn, max_steps=100)\n",
        "\n",
        "# Evaluation.\n",
        "results = linear_est.evaluate(eval_input_fn)\n",
        "print('Accuracy : ', results['accuracy'])\n",
        "print('Dummy model: ', results['accuracy_baseline'])"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "BarkNXwA3rJu"
      },
      "source": [
        "Next let's train a Boosted Trees model. For boosted trees, regression (`BoostedTreesRegressor`) and classification (`BoostedTreesClassifier`) are supported, along with using any twice differentiable custom loss (`BoostedTreesEstimator`). Since the goal is to predict a class - survive or not survive, you will use the `BoostedTreesClassifier`.\n",
        "\n",
        "\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 0,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 51
        },
        "colab_type": "code",
        "id": "tgEzMtlw3rJu",
        "outputId": "96b9c7e3-8aeb-46d9-9605-25b179a4ccfd"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "Accuracy :  0.82575756\n",
            "Dummy model:  0.625\n"
          ]
        }
      ],
      "source": [
        "# Since data fits into memory, use entire dataset per layer. It will be faster.\n",
        "# Above one batch is defined as the entire dataset.\n",
        "n_batches = 1\n",
        "est = tf.estimator.BoostedTreesClassifier(feature_columns,\n",
        "                                          n_batches_per_layer=n_batches)\n",
        "\n",
        "# The model will stop training once the specified number of trees is built, not\n",
        "# based on the number of steps.\n",
        "est.train(train_input_fn, max_steps=100)\n",
        "\n",
        "# Eval.\n",
        "results = est.evaluate(eval_input_fn)\n",
        "print('Accuracy : ', results['accuracy'])\n",
        "print('Dummy model: ', results['accuracy_baseline'])"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "cUrakbu6sqKe"
      },
      "source": [
        "For performance reasons, when your data fits in memory, it is recommended to use the `boosted_trees_classifier_train_in_memory` function. However if training time is not of a concern or if you have a very large dataset and want to do distributed training, use the `tf.estimator.BoostedTrees` API shown above.\n",
        "\n",
        "\n",
        "When using this method, you should not batch your input data, as the method operates on the entire dataset.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 0,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 153
        },
        "colab_type": "code",
        "id": "-4_xz3b_D0W5",
        "outputId": "bbd40462-3b56-4713-941d-8a383188942a"
      },
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "\n",
            "WARNING: The TensorFlow contrib module will not be included in TensorFlow 2.0.\n",
            "For more information, please see:\n",
            "  * https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md\n",
            "  * https://github.com/tensorflow/addons\n",
            "If you depend on functionality not listed there, please file an issue.\n",
            "\n",
            "0.7916667\n"
          ]
        }
      ],
      "source": [
        "def make_inmemory_train_input_fn(X, y):\n",
        "  def input_fn():\n",
        "    return dict(X), y\n",
        "  return input_fn\n",
        "\n",
        "\n",
        "train_input_fn = make_inmemory_train_input_fn(dftrain, y_train)\n",
        "eval_input_fn = make_input_fn(dfeval, y_eval, shuffle=False, n_epochs=1)\n",
        "est = tf.contrib.estimator.boosted_trees_classifier_train_in_memory(\n",
        "    train_input_fn,\n",
        "    feature_columns)\n",
        "print(est.evaluate(eval_input_fn)['accuracy'])"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "hEflwznXvuMP"
      },
      "source": [
        "Now you can use the train model to make predictions on a passenger from the evaluation set. TensorFlow models are optimized to make predictions on a batch, or collection, of examples at once. Earlier,  the `eval_input_fn` is  defined using the entire evaluation set."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 0,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 281
        },
        "colab_type": "code",
        "id": "6zmIjTr73rJ4",
        "outputId": "f9bd7c6e-d1b3-4dc0-ae40-380d4995c749"
      },
      "outputs": [
        {
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYgAAAEICAYAAABF82P+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAFipJREFUeJzt3Xu4XXV95/H3hwQKKMolkUJCCAhY\nGbwxAfVxVCpaGRCw1iI+MoJSqa0jtTod0DrFWn0Gn7Eitp1iRBSpFxAZibe2gFDqVMAAKrcyRC4h\nXKNyVSoC3/ljr1N2T9fJWck5e+9zeb+e5zxZ9/X97STns3+/tfbaqSokSRpvs1EXIEmamQwISVIr\nA0KS1MqAkCS1MiAkSa0MCElSKwNCs0qSzyb5UDP90iQ3Dum8lWSPIZ3r1iSv3MR9L0nyOxOsW5bk\n4SQLxm+b5E1J/n4Dxx3aa62Zw4DQrFVV/1hVz5psuyTHJPnOMGqayapqbVU9taoeb1n3+ar6jbH5\n8YHY9bXW3GJAaGSSLBx1DcM2H9us2cuA0LRqhkfem+T6JPcl+UySLZt1ByRZl+SEJHcDn2mWvybJ\n95Pcn+Sfkjy373gvSHJVkoeSnA1s2bfugCTr+uZ3SXJekvVJfpLkL5M8GzgNeHEzvHJ/s+2vJPlo\nkrVJ7klyWpKt+o71R0nuSnJnkrdO0uZLkvzPJFckeTDJ+Um2b9Ytb96NH5tkLfDtZvlhSa5r2nxJ\nU2e//SZ4DbdL8vWmjfc100vH7fvMSWr5dyHV38tKcmmz+AfNa/aGltd65yRfaeq4Jcnxfev2T7K6\nOf89ST62oddPM5cBoUF4E/Bq4JnAXsD7+9b9KrA9sCtwXJIXAGcAvwvsAHwSWNX8At8C+CpwVrPP\nl4HfajthM67+deA2YDm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A+j1Ei9N8pyqun+kVQ3WG4HPVtWfJ3kxcFaSfarqiVEXNhvN9R5El8d3/Os2SRbS65b+ZCjVDUan\nR5YkeSXwx8BhVfWLIdU2KJO1eRtgH+CSJLfSG6tdNcsvVHf5e14HrKqqX1bVLcD/oxcYs1WXNh8L\nnANQVd8FtqT38MK5aqCPKJrrAdHl8R2rgKOb6dcD367m6s8sNWmbk7wA+CS9cJjt49IwSZur6oGq\nWlRVy6tqOb3rLodV1erRlDstuvzb/iq93gNJFtEbcrp5mEVOsy5tXgscCJDk2fQCYv1QqxyuVcCb\nm7uZXgQ8UFV3TdfB5/QQU03w+I4kHwRWV9Uq4NP0uqFr6F0MOnJ0FU9dxzb/L+CpwJeb6/Frq+qw\nkRU9RR3bPKd0bPPfAb+R5HrgceCPqmrW9o47tvk9wKeS/CG9C9bHzOY3fEm+SC/kFzXXVU4CNgeo\nqtPoXWc5GFgD/Bx4y7Sefxa/dpKkAZrrQ0ySpE1kQEiSWhkQkqRWBoQkqZUBIUlqZUBIkloZEJKk\nVv8f2075URc4nyUAAAAASUVORK5CYII=\n",
            "text/plain": [
              "\u003cFigure size 432x288 with 1 Axes\u003e"
            ]
          },
          "metadata": {
            "tags": []
          },
          "output_type": "display_data"
        }
      ],
      "source": [
        "pred_dicts = list(est.predict(eval_input_fn))\n",
        "probs = pd.Series([pred['probabilities'][1] for pred in pred_dicts])\n",
        "\n",
        "probs.plot(kind='hist', bins=20, title='predicted probabilities')\n",
        "plt.show()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "colab_type": "text",
        "id": "mBUaNN1BzJHG"
      },
      "source": [
        "Finally you can also look at the receiver operating characteristic (ROC) of the results, which will give us a better idea of the tradeoff between the true positive rate and false positive rate."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 0,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 295
        },
        "colab_type": "code",
        "id": "NzxghvVz3rJ6",
        "outputId": "dfcea5c8-7cc2-4cf8-bd83-bb9b675da90d"
      },
      "outputs": [
        {
          "data": {
            "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEWCAYAAACJ0YulAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAIABJREFUeJzt3Xu8VXWd//HXm8NN7sjFCxdBRRFT\nE/GWNVHezUuWY2p2G8uZ0i5Wzmg25tjMzynHLk5ORWWWRWhWDhVmZaLjBQVFQUALBAUEuePhzuF8\nfn+sxXZzPJeF7LX3Pvu8n4/HebAu373WZ3F47Ddrfdf6LkUEZmZmAJ0qXYCZmVUPh4KZmRU4FMzM\nrMChYGZmBQ4FMzMrcCiYmVmBQ8HMzAocClZzJC2StFnSBknLJd0hqVeTNm+T9BdJ9ZLWS/qtpDFN\n2vSR9C1JL6fbWpDODyzvEZmVj0PBatU5EdELeCtwNHDtzhWSTgT+CPwvsD8wEngWeFTSgWmbrsAD\nwOHAGUAf4ERgNXBcXkVL6pzXts2ycChYTYuI5cD9JOGw09eBn0bEtyOiPiLWRMSXgWnADWmbDwPD\ngfMjYm5ENEbEioj4akRMaW5fkg6X9CdJayS9KulL6fI7JP17UbvxkpYUzS+S9C+SZgEb0+l7mmz7\n25JuTaf7SvqRpGWSlkr6d0l1e/hXZQY4FKzGSRoKnAnMT+d7AG8DftlM87uBU9PpU4A/RMSGjPvp\nDfwZ+APJ2cfBJGcaWV0MvAfoB0wCzkq3SfqFfyEwMW17B9CQ7uNo4DTg47uxL7MWORSsVt0rqR5Y\nDKwAvpIu35vk3/2yZj6zDNjZXzCghTYtORtYHhG3RMSW9Azkid34/K0RsTgiNkfES8DTwPnpuncD\nmyJimqR9gLOAz0XExohYAXwTuGg39mXWIoeC1ar3RkRvYDwwmte/7NcCjcB+zXxmP2BVOr26hTYt\nGQYseFOVJhY3m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Og6W90\nb5+nzAAAAABJRU5ErkJggg==\n",
            "text/plain": [
              "\u003cFigure size 432x288 with 1 Axes\u003e"
            ]
          },
          "metadata": {
            "tags": []
          },
          "output_type": "display_data"
        }
      ],
      "source": [
        "from sklearn.metrics import roc_curve\n",
        "\n",
        "fpr, tpr, _ = roc_curve(y_eval, probs)\n",
        "plt.plot(fpr, tpr)\n",
        "plt.title('ROC curve')\n",
        "plt.xlabel('false positive rate')\n",
        "plt.ylabel('true positive rate')\n",
        "plt.xlim(0,)\n",
        "plt.ylim(0,)\n",
        "plt.show()"
      ]
    }
  ],
  "metadata": {
    "colab": {
      "collapsed_sections": [],
      "name": "boosted_trees.ipynb",
      "provenance": [],
      "toc_visible": true,
      "version": "0.3.2"
    },
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}
